import Abstract from '../abstract';

class categoryAPI extends Abstract {
    categoryList(data: { page_size: number; page_current: number }) {
        return this.getReq({url: 'Category.category', params: data});
    }

    CreateCategory(data: { name: string; sort?: any }) {
        return this.postReq({url: 'Category.category', data});
    }

    UpdateCategory(data: { id: any; name: string; sort?: any }) {
        return this.postReq({url: 'Category.category_update', data});
    }

    DelCategory(data: { id: string }) {
        return this.deleteReq({url: 'Category.category', params: data});
    }

    CategorySelect() {
        return this.getReq({url: 'Category.category_select'});
    }

}

// 单列模式返回对象
let instance;
export default (() => {
    if (instance) return instance;
    instance = new categoryAPI();
    return instance;
})();
